﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DanhMuc_ThongTinKhac : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            btnclose.Attributes.Add("onClick", "javascript:history.back(); return false;");
            BindText();
        }
    }
    private void BindText()
    {
        try
        {
            _dbDataContext _db = new _dbDataContext();
            SecurityLib.Sec_AES _ps = new SecurityLib.Sec_AES();
            string madoanvien = _ps.Decrypt(Request.QueryString["codeunionists"].Replace(" ", "+"),"gold",128);
            var val = _db.tblThongTinKhacs.Single(r => r.MaDoanVien.Trim() == madoanvien);
            txtBanThan.Text = val.BanThan.Trim();
            txtNuocNgoai1.Text = val.NuocNgoai1.Trim();
            txtNuocNgoai2.Text = val.NuocNgoai2.Trim();
        }
        catch { }
    }
    protected void btnsave_Click(object sender, EventArgs e)
    {
        _dbDataContext _db = new _dbDataContext();
        SecurityLib.Sec_AES _ps = new SecurityLib.Sec_AES();
        string madoanvien = _ps.Decrypt(Request.QueryString["codeunionists"].Replace(" ", "+"),"gold",128);
        var val = _db.tblThongTinKhacs.Single(r => r.MaDoanVien.Trim() == madoanvien);
        val.BanThan = txtBanThan.Text;
        val.NuocNgoai1 = txtNuocNgoai1.Text;
        val.NuocNgoai2 = txtNuocNgoai2.Text;
        try
        {
            _db.SubmitChanges();
            lblMessage.Text = "Lưu thành công.";
        }
        catch { }
    }
}